﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using GPSCrowdSource.Algorithms;

namespace GPSCrowdSource.DataStructures {

  /// <summary>
  /// Identifies a graph vertex which is also a physical location (usually)
  /// </summary>
  public class Vertex : GeoPosition {

    #region Constructors

    /// <summary>
    /// Make an exact copy.
    /// </summary>
    public Vertex(Vertex inOther) : base(inOther) {
      UserData = inOther.UserData;
      }
    
    /// <summary>
    /// Make a vertex with a unique vertex identifier.
    /// </summary>
    public Vertex(String inID) {
      myUID = inID;
      }

    /// <summary>
    /// Create a vertex with an internally generated unique identifier.
    /// </summary>
    public Vertex() {}

    #endregion

    #region Properties

    /// <summary>
    /// Assign some other (random) user data to this vertex.
    /// </summary>
    public Object UserData { get; set; }

    #endregion

    #region Operators

    public static bool operator==(Vertex a, Vertex b) {
      if( ((Object)a) == null && ((Object)b) == null) return true;
      else if( ((Object)a) == null || ((Object)b) == null) return false;
      return a.Equals(b);
      }

    public static bool operator!=(Vertex a, Vertex b) {
      return !(a == b);
      }
    
    #endregion

    #region Object Overrides
    public override bool Equals(object obj) {
      if(obj == null) return false;
      else if(ReferenceEquals(this,obj)) return true;
      Vertex other = (Vertex)obj;
      return UID == other.UID;
      }

    public override int GetHashCode() {
      return UID.GetHashCode();
      }

    public override string ToString() {
      return UID;
      }

    #endregion

    }

  }
